package org.dydl.service.system.impl;

import java.util.List;

import org.dydl.common.dto.ResponseMessage;
import org.dydl.dao.system.repository.IOrderDetailRepository;
import org.dydl.model.system.OrderDetail;
import org.dydl.service.system.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
//import org.yorma.dao.system.repository.IOrderRepository;

@Service
public class OrderDetailServiceImpl implements OrderDetailService {
	
	@Autowired
	private IOrderDetailRepository orderDetailRepostory;
	
//	@Autowired
//	private IOrderRepository iOrderRepository;
	
	private ResponseMessage res = new ResponseMessage();


	@Override
	public ResponseMessage findByOrderNo(String orderNo) {
		try {
			List<OrderDetail> detailList = orderDetailRepostory.findByOrderNo(orderNo);
			res.setData(detailList);
			res.setSuccess(true);
		} catch (Exception e) {
			res.setSuccess(false);
			res.setMsg(e.getMessage());
		}
		return res;
	}
	
	@Override
	@Transactional
	public ResponseMessage delete(String orderNo) {
		try {
			int deleteStatus = orderDetailRepostory.deleteDetail(orderNo);
			res.setData(deleteStatus);
			res.setSuccess(true);
		} catch (Exception e) {
			res.setSuccess(false);
			res.setMsg(e.getMessage());
		}
		return res;
	}



}
